<template>
  <div draggable="true" @dragstart="dragstart" :id="domId">
    <slot>可拖拽区域</slot>
  </div>
</template>

<script>
import toolRandom from "@/tool/tool-random";

export default {
  props: {
    data: {
      type: [Object, Number, String, Array],
      default: "",
    },
  },
  data() {
    return {
      domId: `id-${toolRandom.randomStr(8)}`,
    };
  },
  methods: {
    dragstart(ev) {
      ev.dataTransfer.setData("data", JSON.stringify(this.data));
      ev.dataTransfer.setData("domId", this.domId);
    },
  },
};
</script>

<style></style>
